﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] arr = { 1,2,3,4,5,6,7,8,9};
            int max = 0;
            int min = 0;
            int sum = 0;
            int avg = 0;
            Test(arr,max,min,out sum,avg);
            Console.WriteLine("最大值："+max);
            Console.WriteLine("最小值："+min);
            Console.WriteLine("总和："+sum);
            Console.WriteLine("平均数："+avg);
            Console.ReadKey();
        }
        public static void Test( int []arr, int max, int min,out int sum, int avg)
        {
            max = arr[0];
            min = arr[0];
            sum = 0;
            for (int i = 0; i < arr.Length; i++)
            {
                if (arr[i] > max)
                {
                    max = arr[i];
                }
                if (arr[i] < min)
                {
                    min = arr[i];
                }
                sum += arr[i];
            }
            avg = sum / arr.Length;
        }//ref 需要在外部赋好值
         //out 需要在内部赋好值
    }
}
